﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using dpptask2.Exceptions;

namespace dpptask2.OptionClasses
{
    public class optionNoParamAttribute : optionAttribute
    {
        public override void  parse(object argumentClass, CmdLineToken choiceToken, CmdLineToken parameterToken)
 	    {
            if (choiceToken == null)
            {
                if (this.choiceRequired)
                    throw new ParserException("Choice {0} required.", this.command);
                else
                    this.field.SetValue(argumentClass, false);
            }
            else
            {
                choiceToken.isUsed = true;
                this.field.SetValue(argumentClass, true);
            }
        }

        public optionNoParamAttribute()
        {
            this.choiceRequired = false;
        }
        
        public override Type typeAccepted()
        {
            return typeof(bool);
        }

        public override string getUsageText(string cmd)
        {
            return addSlashes(cmd);
        }
    }
}
